package jp.sourceforge.akjrcp.flvtools.search;

import java.io.File;
import java.io.IOException;

import jp.sourceforge.akjrcp.ui.DirectoryList;

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;

public class FirefoxUtil {
	protected static  Image firefoxImage =new Image(Display.getCurrent(), DirectoryList.class.getClassLoader()
            .getResourceAsStream(
            "jp/sourceforge/akjrcp/flvtools/resource/firefox_icon.png"));;
          
            protected static  Image otherImage =new Image(Display.getCurrent(), DirectoryList.class.getClassLoader()
                    .getResourceAsStream(
                    "jp/sourceforge/akjrcp/flvtools/resource/other_icon.png"));;
           
	public static Image getFirefoxImage(){
		return firefoxImage;
	}
	public static String firefoxPath="C:\\Program Files\\Mozilla Firefox\\firefox.exe";
	public static boolean isAvailable(){
		return new File(firefoxPath).exists();
	}
	public static String getFirefoxPath(){
		return firefoxPath;
	}
	public static void openURL(String url){
		Thread t=new FirefoxOpen(url);
		t.start();
		
		
	}
	public static class FirefoxOpen extends Thread{
		private String url;
		FirefoxOpen(String url){
			this.url=url;
		}
		
		public void run(){
			Runtime runtime=Runtime.getRuntime();
			String args[]=new String[]{firefoxPath,url};
			try {
				Process p=runtime.exec(args);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}
	public static Image getOtherImage() {
		// TODO Auto-generated method stub
		return otherImage;
	}

}
